package com.financing.wap.web.controller.api;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.financing.wap.common.ResultMap;
import com.financing.wap.common.ResultMap.STATUS;
import com.financing.wap.dto.VisitRecordDTO;
import com.financing.wap.service.IProductService;
import com.financing.wap.service.IVisitRecordService;
import com.financing.wap.web.controller.BaseController;

@Controller("apiVisitRecordController")
@RequestMapping("/api/visitRecord")
public class VisitRecordController  extends BaseController{

	Logger logger = Logger.getLogger(getClass());

	@Autowired
	private IVisitRecordService visitRecordService;
	@Autowired
	private IProductService productService;

	/**
	 * 预约
	 * @return
	 */
	@RequestMapping("/service")
	@ResponseBody
	public ResultMap service(HttpServletRequest request, HttpServletResponse response,VisitRecordDTO visitRecordDto){
		ResultMap result = new ResultMap();
		try {
			
			visitRecordDto.setSessionId(request.getSession().getId());
			visitRecordDto.setVisitDate(new Date());
			Integer id = visitRecordService.insertVisitRecord(visitRecordDto);

			result.setStatus(STATUS.SUCCESS);
			result.setAttribute("id", id);
			result.setStatusCode(ResultMap.STATUS_CODE_SUCCESS);
		}catch(Exception e) {
			logger.warn("==>warn messang:"+e.getMessage());
			result.setStatus(STATUS.ERROR);
			result.setStatusCode(ResultMap.STATUS_CODE_SYS_EXCEPTION);
		}


		return result;
	}


}
